import { createRouter, createWebHashHistory } from "vue-router";

// 创建路由器
const router = createRouter({
  // 路由模式：hash
  history: createWebHashHistory(),
  // 路由表
  routes: [
    {
      path: "/",
      redirect: "/home",
      name: "Index",
      component: () => import("@/layout/layout.vue"),
      children: [
        {
          path: "/home",
          name: "Home",
          component: () => import("@/views/home/index.vue"),
        },
        {
          path: "/user/user",
          name: "User",
          component: () => import("@/views/user/user.vue"),
        },
        {
          path: "/user/role",
          name: "Role",
          component: () => import("@/views/user/role.vue"),
        },
        {
          path: "/product/product",
          name: "Product",
          component: () => import("@/views/product/product.vue"),
        },
        {
          path: "/product/brand",
          name: "Brand",
          component: () => import("@/views/product/brand.vue"),
        },
      ],
    },
    // 数据大屏
    {
      path: "/screen",
      name: "Screen",
      component: () => import("@/views/screen/screen.vue"),
    },
    {
      path: "/login",
      // 命名路由，做路由权限时需要用到
      name: "login",
      component: () => import("@/views/login/login.vue"),
    },
    {
      // 404路由
      path: "/404",
      name: "404",
      component: () => import("@/views/404/index.vue"),
    },
    {
      // 任意路由，上面的都没匹配上，就会匹配这个路由，一般放在最后
      path: "/:pathMatch(.*)*",
      name: "Any",
      redirect: "/404",
    },
  ],
});

export default router;
